package com.zhxi.gulimall.file.config;

import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Zhxi
 */
@Configuration
@Slf4j
public class MinIOConfiguration {
    @Value("${minio.url}")
    String endPoint;
    @Value("${minio.accessKey}")
    String accessKey;
    @Value("${minio.secretKey}")
    String secretKey;

    @Bean
    public MinioClient minioClient() {

        return MinioClient.builder()
                .endpoint(endPoint)
                .credentials(accessKey, secretKey)
                .region("cn-north-1")  // 这里设置为正确的区域
                .build();
    }

}